package com.smart.advisor;

import java.lang.reflect.Method;

import org.springframework.aop.ClassFilter;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;

public class GreetingAdvisor extends StaticMethodMatcherPointcutAdvisor {

    /**
     * 切入点匹配规则
     * @param method
     * @param clazz
     * @return
     */
    public boolean matches(Method method, Class clazz) {
        return "greetTo".equals(method.getName()); // 在greetTo方法调用前织入一个增强
    }

    /**
     * 切入点的匹配规则为Waiter类以及其子类
     * @return
     */
    public ClassFilter getClassFilter() {
        return clazz -> Waiter.class.isAssignableFrom(clazz);

    }
}
